package com.example.job;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;

import java.time.LocalTime;
//定义简单任务类
public class MySimpleJob implements SimpleJob {
    //ShardingContext 分片上下文 包含分片项 总分片数 任务ID
    @Override
    public void execute(ShardingContext shardingContext) {
        LocalTime time = LocalTime.now();
        System.out.println(time+",我是分片项："+shardingContext.getShardingItem()+
                ",总分片项："+shardingContext.getShardingTotalCount()+",taskId"+
                shardingContext.getTaskId());
       /* int shard = shardingContext.getShardingItem();
        if(shard==0){
            //do something
        }
        else if (shard==1){
            //do otherthing
        }
        else{
            //......
        }*/
    }
}
